//
//  MyChatViewController.m
//  MyYiJianKangApp
//
//  Created by 张国文 on 16/4/6.
//  Copyright © 2016年 hangzhouyijiyin. All rights reserved.
//

#import "MyChatViewController.h"
#import "ChatRoomMemberViewController.h"
#import "MyCreateGroupDetailViewController.h"
#import "MyJoinGroupViewController.h"

@interface MyChatViewController ()

@end

@implementation MyChatViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    // navi的修改
    [self changeNavigation];
    
    
}


// navi的修改
- (void)changeNavigation
{
    [self.navigationController.navigationBar setTranslucent:NO];
    self.navigationItem.title = self.title;
    UIImageView *leftImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 30, 30)];
    leftImageView.image = [UIImage imageNamed:@"houtui"];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:leftImageView];
    UITapGestureRecognizer *leftTapGes = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(lastPage:)];
    [leftImageView addGestureRecognizer:leftTapGes];
    
    if (self.conversationType == ConversationType_CHATROOM) {
        UIBarButtonItem *rightItem = [[UIBarButtonItem alloc] initWithTitle:@"成员列表" style:UIBarButtonItemStyleDone target:self action:@selector(chatMemberList:)];
        rightItem.tintColor = [UIColor whiteColor];
        self.navigationItem.rightBarButtonItem = rightItem;
    } else if (self.conversationType == ConversationType_GROUP) {
        NSLog(@"我的群组model:%@, 创建还是加入:%@", self.myGroupModel, self.createOrJoin);
        // group-myGroup
        UIImageView *rightImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 30, 30)];
        rightImageView.image = [UIImage imageNamed:@"group-myGroup"];
        self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:rightImageView];
        // 添加手势
        UITapGestureRecognizer *rightTapGes = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(detailGroup:)];
        [rightImageView addGestureRecognizer:rightTapGes];
    } else if (self.conversationType == ConversationType_PRIVATE) {
        // 说明是私有聊天
        UIImageView *rightImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 30, 30)];
        rightImageView.image = [UIImage imageNamed:@"friendImage-gongyou"];
        self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:rightImageView];
        // 添加手势
        UITapGestureRecognizer *rightTapGes = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(detailFriend:)];
        [rightImageView addGestureRecognizer:rightTapGes];
    }
    
}

#pragma mark - 返回上一页面
- (void)lastPage:(UITapGestureRecognizer *)tapGes
{
    [self.navigationController popViewControllerAnimated:YES];
}

#pragma mark - 成员列表
- (void)chatMemberList:(UIBarButtonItem *)barItem
{
    NSLog(@"聊天水成员列表");
    ChatRoomMemberViewController *chatRoomMemberVC = [[ChatRoomMemberViewController alloc] init];
    [self.navigationController pushViewController:chatRoomMemberVC animated:YES];
}

#pragma mark - 小组详情
- (void)detailGroup:(UITapGestureRecognizer *)tagGes
{
    NSLog(@"进入小组详情");
    if ([self.createOrJoin isEqualToString:@"create"]) {
        // 说明是创建的
        MyCreateGroupDetailViewController *myCreateDetailVC = [[MyCreateGroupDetailViewController alloc] init];
        [self.navigationController pushViewController:myCreateDetailVC animated:YES];
    } else if ([self.createOrJoin isEqualToString:@"join"]) {
        MyJoinGroupViewController *myJoinCreateDetailVC = [[MyJoinGroupViewController alloc] init];
        [self.navigationController pushViewController:myJoinCreateDetailVC animated:YES];
    }
}

#pragma mark - 好友详情
- (void)detailFriend:(UITapGestureRecognizer *)tapGes
{
    NSLog(@"进入好友详情");
}






- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
